<script setup lang="ts">
// import {WelcomeItem} from '../components/WelcomeItem'
import type {MessageProps} from '../types'
import { defineProps, withDefaults,ref,onMounted } from 'vue'
 const visible=ref(true)
 const props=withDefaults( defineProps<MessageProps>(),{
  duration: 3000,
  showClose: true,
  type: 'info',
  message: 'message',
  onClose: () => {
    console.log('close')
  }
})
function startTimer(){
  if(props.duration===0) return
  setTimeout(() => {
    visible.value=false
    props.onClose()
  }, props.duration);
}
onMounted(()=>{
  startTimer()
})
</script>
<template>
    <div>
        <h1 v-show="visible">{{ message }}</h1>
    </div>
</template>
